package simbot.example.listener;

import catcode.Neko;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.db.nosql.redis.RedisDS;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.extern.slf4j.Slf4j;
import love.forte.common.ioc.annotation.Beans;
import love.forte.simbot.annotation.Filter;
import love.forte.simbot.annotation.OnGroup;
import love.forte.simbot.api.message.MessageContent;
import love.forte.simbot.api.message.MessageContentBuilder;
import love.forte.simbot.api.message.MessageContentBuilderFactory;
import love.forte.simbot.api.message.containers.AccountInfo;
import love.forte.simbot.api.message.containers.GroupAccountInfo;
import love.forte.simbot.api.message.containers.GroupInfo;
import love.forte.simbot.api.message.events.GroupMsg;
import love.forte.simbot.api.message.results.GroupMemberInfo;
import love.forte.simbot.api.message.results.GroupMemberList;
import love.forte.simbot.api.sender.Getter;
import love.forte.simbot.api.sender.Sender;
import love.forte.simbot.filter.MatchType;
import org.omg.CORBA.portable.ResponseHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.*;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import simbot.example.config.RestTemplateConfig;
import simbot.example.entity.*;
import simbot.example.game.wuziqi;
import simbot.example.mapper.*;
import simbot.example.shop.BuyItem;
import simbot.example.util.CommonUtil;
import simbot.example.xxjob.TimedTask;

import javax.annotation.Resource;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import java.math.BigDecimal;

import static simbot.example.config.RestTemplateConfig.proxy;

/**
 * 群消息监听的示例类。
 * 所有需要被管理的类都需要标注 {@link Service} 注解。
 * <p>
 * 由于当前是处于springboot环境下，因此强烈建议类上的注释使用：
 * <ul>
 *     <li>{@link org.springframework.stereotype.Component}</li>
 *     <li>{@link Service}</li>
 * </ul>
 * 等注解来代替simbot的 {@link Beans}。
 * <p>
 * 同样的，依赖注入也请使用 {@link org.springframework.beans.factory.annotation.Autowired} 等Springboot相关的注解。
 *
 * @author ForteScarlet
 */
@Slf4j
@Service
public class MyGroupListen {

    @Autowired
    private MessageContentBuilderFactory messageBuilderFactory;
    //    @Resource
//    private QuestionMapper questionMapper;
    @Resource
    private TimedTask timedTask;

    @Resource
    private QuestionjiuMapper questionjiuMapper;
    @Resource
    private CommonUserMapper commonUserMapper;
    @Resource
    private SignUserMapper signUserMapper;
    @Resource
    private StoryMapper storyMapper;
    @Resource
    private HerouserMapper herouserMapper;
    @Resource
    private HerosinformationMapper herosinformationMapper;
    @Resource
    private RestTemplate restTemplate;
    @Resource
    private ExerciseMapper exerciseMapper;
    @Resource
    private wuziqi wzq;
    @Resource
    private BuyItem buyItem;
    @Resource
    private ItemsJiuMapper itemsJiuMapper;
    @Resource
    private InformationMapper informationMapper;


    @Value("${customize.qqGroupNum}")
    private Long qqGroupNum;
    @Value("${customize.key}")
    private String key;
    public Sender comSender;

    String lastMeg = null;
    int pictureCont = 0;

    /**
     * log
     */
    private static final Logger LOG = LoggerFactory.getLogger(MyGroupListen.class);


    /**
     * 此监听函数代表，收到消息的时候，将消息的各种信息打印出来。
     * <p>
     * 此处使用的是模板注解 {@link OnGroup}, 其代表监听一个群消息。
     * <p>
     * 由于你监听的是一个群消息，因此你可以通过 {@link GroupMsg} 作为参数来接收群消息内容。
     */


    private String teacher1;
    private String temporaryQuestion1;
    private String temporaryAnswer1;
    private String questionType1;
    int messageCont = 1;

    @OnGroup
    public void anotherLiaotian(GroupMsg groupMsg, Sender sender) throws IOException, InterruptedException {
//        if (groupMsg.getGroupInfo().getGroupCode().equals("909858105")){
        //信息构建工厂
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();

        // 获取发消息的人。
        GroupAccountInfo accountInfo = groupMsg.getAccountInfo();
        String files = "D:\\steam\\steamapps\\common\\图库\\";

        if (groupMsg.getText().equals(lastMeg)) {
            messageCont++;
            if (messageCont > 3) {
                sender.sendGroupMsg(groupMsg, groupMsg.getMsgContent());
                messageCont = 1;
            }
        } else {
            messageCont = 1;
            lastMeg = groupMsg.getText();
        }


        comSender = sender;
        String getText = groupMsg.getText();
        String cat;
        cat = "[CAT:text,text=" + getText + "]";
        List<Neko> imageCats = groupMsg.getMsgContent().getCats("image");
        for (Neko image : imageCats) {
            File isExists = new File(files + image.get("id"));
            if (!isExists.exists() && teacher1 != null) {
                CommonUtil.downloadPicture(image.get("url"), files + image.get("id"));
            }
            cat = cat + "[CAT:image,file=" + files + image.get("id") + "]";
        }
        List<Questionjiu> questions = null;

        if (imageCats.size() == 0) {
            try {
                questions = questionjiuMapper.selectsenteces(groupMsg.getText());
            } catch (Exception ignored) {

            }
        } else {
            questions = questionjiuMapper.selectList(Wrappers.<Questionjiu>lambdaQuery().eq(Questionjiu::getQuestion, cat));
        }


        System.out.println(groupMsg.getMsgContent().getCats());


        if (groupMsg.getText().trim().equals("早苗体重")){
            Information information = informationMapper.selectById(1);
            sender.sendGroupMsg(groupMsg,"人家才"+information.getWeight()+"kg。");
            return;
        }

        //识图
        if (groupMsg.getText().trim().equals("识图")) {
            String url = imageCats.get(0).get("url");
            System.out.println(url);
            String result = restTemplate.getForObject("https://saucenao.com/search.php?url=" + url.substring(0, url.length() - 7) + "&output_type=2&api_key=" + key + "&db=999&numres=3", String.class);
            JSONObject jsonObject = JSONObject.parseObject(result);
            System.out.println(jsonObject);
            List<JSONObject> list = CommonUtil.jsonToList(jsonObject.getString("results"));
            String s = "";
            MessageContent messageContent = null;
            for (JSONObject object : list) {
//                String file2 = "D:\\steam\\steamapps\\common\\识图\\"+i+".jpg";
//                CommonUtil.downloadPicture(list.get(i).getJSONObject("header").getString("thumbnail"), file2);
                try {
                    JSONArray objects = JSONArray.parseArray(object.getJSONObject("data").getString("ext_urls"));
                    if (object.getJSONObject("data").containsKey("jp_name")) {
                        s = s + "标题：" + object.getJSONObject("data").getString("jp_name") + "\n相似度：" + object.getJSONObject("header").getString("similarity") + "%\n来源：" + objects.getString(0) + "\n";
                    } else {
                        s = s + "标题：" + object.getJSONObject("data").getString("title") + "\n相似度：" + object.getJSONObject("header").getString("similarity") + "%\n来源：" + objects.getString(0) + "\n";
                    }
                } catch (Exception e) {
                    if (object.getJSONObject("data").containsKey("jp_name")) {
                        s = s + "标题：" + object.getJSONObject("data").getString("jp_name") + "\n相似度：" + object.getJSONObject("header").getString("similarity") + "%\n";
                    } else {
                        s = s + "标题：" + object.getJSONObject("data").getString("title") + "\n相似度：" + object.getJSONObject("header").getString("similarity") + "%\n";
                    }
                }
                messageContent = builder.text(s).imageUrl(object.getJSONObject("header").getString("thumbnail")).build();
                s = "";
            }

            sender.sendGroupMsg(groupMsg, messageContent);
            return;

        }


        //发涩图功能
        if (groupMsg.getText().contains("涩图") || groupMsg.getText().contains("色图")) {
            RestTemplate restTemplate1 = new RestTemplate();
            if (pictureCont > 8) {
                pictureCont = 0;
            }
            int cont = pictureCont;
            String file = "D:\\steam\\steamapps\\common\\setu\\" + cont + ".jpg";
            String url;
            if (groupMsg.getText().endsWith("涩图") || groupMsg.getText().endsWith("色图")) {
                url = "https://api.lolicon.app/setu/v2?R18=1&tag=" + groupMsg.getText().substring(0, groupMsg.getText().length() - 2);
            } else {
                url = "https://api.lolicon.app/setu/v2?R18=1";
            }
            pictureCont++;
            String getPhoto = restTemplate1.getForObject(url, String.class);
            JSONObject jsonObject = JSONObject.parseObject(getPhoto);
            List<JSONObject> list = CommonUtil.jsonToList(jsonObject.getString("data"));
            if (list.size() == 0) {
                sender.sendGroupMsg(groupMsg, "未找到指定图片");
                return;
            }
            restTemplate1.setRequestFactory(proxy());
            HttpHeaders headers = new HttpHeaders();
            headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
            headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
            HttpEntity<String> entity = new HttpEntity<>("parameters", headers);
            ResponseEntity<byte[]> responseEntity = restTemplate1.exchange(list.get(0).getJSONObject("urls").getString("original"), HttpMethod.GET, entity, byte[].class);
            //获取entity中的数据
            byte[] body = responseEntity.getBody();
            //创建输出流  输出到本地
            FileOutputStream fileOutputStream = new FileOutputStream(new File(file));
            fileOutputStream.write(body);
            //关闭流
            fileOutputStream.close();
            MessageContent messageContent = builder.text("pid:" + list.get(0).getString("pid") + "\n标题:" + list.get(0).getString("title") + "\n")
                    .imageLocal(file)
                    .build();
            sender.sendGroupMsg(groupMsg, messageContent);
            return;
        }


//        if (groupMsg.getText().contains("涩图") || groupMsg.getText().contains("色图")) {
//            String url = "https://api.lolicon.app/setu/v1?R18=0";
//
//
//            String result = HttpUtil.get(url);
//            JSONObject jsonObject = JSONObject.parseObject(result);
//            List<JSONObject> list = CommonUtil.jsonToList(jsonObject.getString("data"));
//            String file = "D:\\steam\\steamapps\\common\\图库\\1.jpg";
//            ResponseEntity<byte[]> responseEntity = restTemplate.exchange(list.get(0).getString("url"), HttpMethod.GET, null, byte[].class);
//            //获取entity中的数据
//            byte[] body = responseEntity.getBody();
//            //创建输出流  输出到本地
//            FileOutputStream fileOutputStream = new FileOutputStream(new File(file));
//            fileOutputStream.write(body);
//            //关闭流
//            fileOutputStream.close();
//            sender.sendGroupMsg(groupMsg,"[CAT:image,file="+file+"]");
//        }


        //菜单
        if (groupMsg.getText().equals("菜单") || groupMsg.getText().trim().equals("cd")) {
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n绑定角色三摆名\njjc(可加三摆名)\ntf(可加三摆名)\npw(可加三摆名)\nsdz(可加三摆名)\n涩图或色图\n抽签\n解签\n今日运气\n点歌+歌名\n投喂\n信仰\n新闻\n早苗商店").build();
            sender.sendGroupMsg(groupMsg, msg);
        }


        //新闻
        if (groupMsg.getText().equals("新闻")) {
            sender.sendGroupMsg(groupMsg, "[CAT:text,text=来看看今天又发生了什么吧\n][CAT:image,url=http://api.03c3.cn/zb]");
        }


        //学习模块
        if (accountInfo.getAccountCode().equals(teacher1) && !groupMsg.getText().equals("取消") && questionType1.equals("answer")) {
            temporaryAnswer1 = cat;
            Questionjiu insertQuestion = new Questionjiu();
            insertQuestion.setQuestion(temporaryQuestion1);
            insertQuestion.setAnswer(temporaryAnswer1);
            insertQuestion.setPerson(accountInfo.getAccountCode());
            questionjiuMapper.insert(insertQuestion);
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("学习成功").build();
            sender.sendGroupMsg(groupMsg, msg);
            teacher1 = null;
            temporaryQuestion1 = null;
            temporaryAnswer1 = null;
            questionType1 = null;
            return;
        }

        if (groupMsg.getText().equals("取消")) {
            teacher1 = null;
            temporaryQuestion1 = null;
            temporaryAnswer1 = null;
            questionType1 = null;
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("取消学习").build();
            sender.sendGroupMsg(groupMsg, msg);
            return;
        }

        if (accountInfo.getAccountCode().equals(teacher1) && !groupMsg.getText().equals("取消") && questionType1.equals("question")) {
            questionType1 = "answer";
            if (imageCats.size() == 0) {
                temporaryQuestion1 = groupMsg.getText();
            } else {
                temporaryQuestion1 = cat;
            }


            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("请输入回答\n输入取消可以退出学习").build();
            sender.sendGroupMsg(groupMsg, msg);
            return;
        }

        if (groupMsg.getText().equals("早苗学习") && teacher1 == null) {
            teacher1 = accountInfo.getAccountCode();
            questionType1 = "question";
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("请输入问题\n输入取消可以退出学习").build();
            sender.sendGroupMsg(groupMsg, msg);
            return;
        }


        if (groupMsg.getText().equals("今日运气")) {
            String now = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now());
            List<CommonUser> commonUserList = commonUserMapper.selectList(Wrappers.<CommonUser>lambdaQuery().eq(CommonUser::getUserNum, accountInfo.getAccountCode()));
            if (commonUserList.size() == 0) {
                CommonUser commonUser = new CommonUser();
                commonUser.setUserNum(accountInfo.getAccountCode());
                commonUser.setIsSign(now);
                String yesterday = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now().minusDays(1));
                commonUser.setIsFeed(yesterday);
                commonUser.setBelief("0");
                int getLuck = (int) (Math.random() * 100);
                String string = "今日运气值：" + getLuck;
                if (0 <= getLuck && getLuck < 20) {
                    string = string + "(危)";
                } else if (20 <= getLuck && getLuck < 40) {
                    string = string + "(小吉)";
                } else if (40 <= getLuck && getLuck < 60) {
                    string = string + "(中吉)";
                } else if (60 <= getLuck && getLuck < 80) {
                    string = string + "(大吉)";
                } else {
                    string = string + "(太好了)";
                }
                commonUserMapper.insert(commonUser);
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text(string).build();
                sender.sendGroupMsg(groupMsg, msg);
            } else {
                if (commonUserList.get(0).getIsSign().equals(now)) {
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text("今天已经测过了哦！").build();
                    sender.sendGroupMsg(groupMsg, msg);
                } else {
                    commonUserList.get(0).setIsSign(now);
                    int getLuck = (int) (Math.random() * 100);
                    String string = "今日运气值：" + getLuck;
                    if (0 <= getLuck && getLuck < 20) {
                        string = string + "(危)";
                    } else if (20 <= getLuck && getLuck < 40) {
                        string = string + "(小吉)";
                    } else if (40 <= getLuck && getLuck < 60) {
                        string = string + "(中吉)";
                    } else if (60 <= getLuck && getLuck < 80) {
                        string = string + "(大吉)";
                    } else {
                        string = string + "(太好了)";
                    }
                    commonUserMapper.update(commonUserList.get(0), Wrappers.<CommonUser>lambdaQuery().eq(CommonUser::getUserNum, accountInfo.getAccountCode()));
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text(string).build();
                    sender.sendGroupMsg(groupMsg, msg);
                }
            }
            return;
        }

        //回答模块
        if (questions.size() != 0 && questionType1 == null && !groupMsg.getText().startsWith("查询")) {
            if (groupMsg.getMsgContent().getCats("at").size() != 0) {
                if (groupMsg.getMsgContent().getCats("at").get(0).get("code").equals("927114078")) {
                    int as = (int) (Math.random() * (questions.size()));
                    System.out.println(questions.get(as).getAnswer());
                    sender.sendGroupMsg(groupMsg, questions.get(as).getAnswer());
                }
            } else {
                if ((int) (Math.random() * 100) > 80) {
                    int as = (int) (Math.random() * (questions.size()));
                    System.out.println(questions.get(as).getAnswer());
                    sender.sendGroupMsg(groupMsg, questions.get(as).getAnswer());
                }
            }
        }
    }


    @Filter(value = "查询", matchType = MatchType.STARTS_WITH, trim = true)
    @OnGroup
    public void anotherSelectSentence(GroupMsg groupMsg, Sender sender) {
        String getText = groupMsg.getText();
        String cat = "";
        if (null != getText) {
            cat = "[CAT:text,text=" + groupMsg.getText().substring(2) + "]";
        }
        List<Neko> imageCats = groupMsg.getMsgContent().getCats("image");
        for (Neko image : imageCats) {
            cat = cat + "[CAT:image,id=" + image.get("id") + "]";
        }

        List<Questionjiu> questions = null;

        if (imageCats.size() == 0) {
            try {
                questions = questionjiuMapper.selectsenteces(groupMsg.getText());
            } catch (Exception ignored) {

            }
        } else {
            questions = questionjiuMapper.selectList(Wrappers.<Questionjiu>lambdaQuery().eq(Questionjiu::getQuestion, cat));
        }

        String result = "";
        for (Questionjiu question : questions) {
            String i = question.getId();
            String q = "";
            q = q + question.getQuestion();
            String a = "";
            if (null != Neko.of(question.getAnswer()).get("text")) {
                a = a + Neko.of(question.getAnswer()).get("text");
            }
            if (null != Neko.of(question.getAnswer()).get("image")) {
                a = a + Neko.of(question.getAnswer()).get("image");
            }
            String p = question.getPerson();

            String all = i + " " + q + " " + a + " " + p + "\n";
            result = result + all;
        }

        MessageContentBuilder build = messageBuilderFactory.getMessageContentBuilder();
        MessageContent msg = build.text(result + "用‘删除+编号’来删除").build();

        sender.sendGroupMsg(groupMsg, msg);


    }


    @Filter(value = "删除", matchType = MatchType.STARTS_WITH, trim = true)
    @OnGroup
    public void anotherDeleteSentence(GroupMsg groupMsg, Sender sender) {

//        if (groupMsg.getGroupInfo().getGroupCode().equals("909858105")) {
        // 获取发消息的人。
        GroupAccountInfo accountInfo = groupMsg.getAccountInfo();

        try {

            int b = Integer.valueOf(groupMsg.getText().substring(2)).intValue();
            questionjiuMapper.deleteById(b);

        } catch (NumberFormatException e) {

            e.printStackTrace();

        }


        MessageContentBuilder build = messageBuilderFactory.getMessageContentBuilder();
        MessageContent msg = build.text("删除成功").build();

        sender.sendGroupMsg(groupMsg, msg);
//        }
    }

    public void task(int state) {
        Story story = storyMapper.selectOne(Wrappers.<Story>lambdaQuery().eq(Story::getFlag, "1"));
//        int rand = (int) (Math.random() * 80);
        LocalDateTime notTime = LocalDateTime.now();


        if (notTime.getMinute() == 0 && notTime.getHour() > 6 && notTime.getHour() != state) {
            if (notTime.getHour() == 7) {
                comSender.sendGroupMsg(qqGroupNum, "[CAT:text,text=早上好!来看看今天又发生了什么吧\n][CAT:image,url=http://api.03c3.cn/zb]");
                comSender.sendGroupMsg(1105494927, "[CAT:text,text=早上好!来看看今天又发生了什么吧\n][CAT:image,url=http://api.03c3.cn/zb]");

//            } else {
//                if (notTime.getHour() == 15) {
//                    comSender.sendGroupMsg(909858105, "下午好，摸鱼人！\n" + "工作再累，一定不要忘记摸鱼哦！\n" + "有事没事起身去茶水间，去厕所，去廊道走走\n" + "别老在工位上坐着，钱是老板的,但命是自己的\n" + "上班是帮老板赚钱，摸鱼是赚老板的钱！\n" + "最后，祝愿天下所有摸鱼人，都能愉快的渡过每一天…");
//                } else if(notTime.getHour() == 8) {
//                    comSender.sendGroupMsg(909858105, "好饿呀，想要吃小饼干~");
//                }else if (notTime.getHour() == 12) {
//                    comSender.sendGroupMsg(909858105, "富婆，饿饿，饭饭。");
//                }else if (notTime.getHour() == 18) {
//                    comSender.sendGroupMsg(909858105, "好饿呀，晚上我能去你家吃饭吗？就亿碗。");
//                }else {
//                    comSender.sendGroupMsg(909858105, LocalDateTime.now().getHour() + "点了，" + sentences[rand]);
//                }
            }
            timedTask.setState(notTime.getHour());
        }
    }

    @OnGroup
    public void about300Hero(GroupMsg groupMsg, Sender sender) {
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();

        AccountInfo accountInfo = groupMsg.getAccountInfo();
        if (groupMsg.getText().startsWith("tf")) {
            if (groupMsg.getText().trim().equals("tf")) {
                List<Herouser> herouser;
                if (groupMsg.getMsgContent().getCats().size() > 1) {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, groupMsg.getMsgContent().getCats().get(1).get("code")));
                    System.out.println(herouser);
                } else {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, accountInfo.getAccountCode()));
                }
                if (herouser.size() == 0) {
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text("还未绑定角色！").build();
                    sender.sendGroupMsg(groupMsg, msg);
                } else {
                    String result = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchNormal?type=wx/AccountID=0&Guid=0&RoleName=" + herouser.get(0).getRolename(), new JSONObject(), String.class);
                    JSONObject data = JSONObject.parseObject(result).getJSONObject("data");
                    if (!data.containsKey("MatchSportsList")) {
                        MessageContent msg = builder.at(accountInfo.getAccountCode()).text("该角色名不存在！").build();
                        sender.sendGroupMsg(groupMsg, msg);
                        return;
                    }
                    List<JSONObject> mathSportList = CommonUtil.jsonToList(data.getString("MatchSportsList"));
                    String roleName = data.getString("RoleName");
                    int teamScore = new Double(Double.valueOf(data.getString("TeamScore"))).intValue();
                    int masterLv = new Double(Double.valueOf(data.getString("MasterLv"))).intValue();
                    int totalSign = new Double(Double.valueOf(mathSportList.get(0).getJSONObject("MatchSports").getString("Win"))).intValue();
                    int total = new Double(Double.valueOf(mathSportList.get(0).getJSONObject("MatchSports").getString("Total"))).intValue();
                    String winRate = String.valueOf(CommonUtil.divide(totalSign, total, 3) * 100);
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n角色名：" + roleName + "\n等  级：" + masterLv + "\n团  分：" + teamScore + "\n胜 率：" + winRate.substring(0, 4) + "%").build();
                    sender.sendGroupMsg(groupMsg, msg);
                }
            } else {
                String getName = groupMsg.getText().trim().substring(2);
                String result = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchNormal?type=wx/AccountID=0&Guid=0&RoleName=" + getName, new JSONObject(), String.class);
                JSONObject data = JSONObject.parseObject(result).getJSONObject("data");
                List<JSONObject> mathSportList = CommonUtil.jsonToList(data.getString("MatchSportsList"));
                String roleName = data.getString("RoleName");
                int teamScore = new Double(Double.valueOf(data.getString("TeamScore"))).intValue();
                int masterLv = new Double(Double.valueOf(data.getString("MasterLv"))).intValue();
                int totalSign = new Double(Double.valueOf(mathSportList.get(0).getJSONObject("MatchSports").getString("Win"))).intValue();
                int total = new Double(Double.valueOf(mathSportList.get(0).getJSONObject("MatchSports").getString("Total"))).intValue();
                String winRate = String.valueOf(CommonUtil.divide(totalSign, total, 3) * 100);
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n角色名：" + roleName + "\n等  级：" + masterLv + "\n团  分：" + teamScore + "\n胜 率：" + winRate.substring(0, 4) + "%").build();
                sender.sendGroupMsg(groupMsg, msg);
            }
        }

        if (groupMsg.getText().startsWith("绑定角色")) {
            String getName = groupMsg.getText().trim().substring(4).trim();
            List<Herouser> herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getRolename, getName));
            System.out.println(herouser);
            if (herouser.size() == 0) {
                String result = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchNormal?type=wx/AccountID=0&Guid=0&RoleName=" + getName, new JSONObject(), String.class);
                JSONObject data = JSONObject.parseObject(result).getJSONObject("data");
                if (!data.containsKey("RoleID")) {
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text("该角色名不存在！").build();
                    sender.sendGroupMsg(groupMsg, msg);
                    return;
                }
                Long roleID = data.getLong("RoleID");
                Herouser insertUser = new Herouser();
                insertUser.setUsername(accountInfo.getAccountCode());
                insertUser.setRolename(data.getString("RoleName"));
                insertUser.setRoleid(String.valueOf(roleID));
                herouserMapper.insert(insertUser);
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text("绑定成功！").build();
                sender.sendGroupMsg(groupMsg, msg);
            } else {
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text("该角色已绑定！").build();
                sender.sendGroupMsg(groupMsg, msg);
            }
        }

        if (groupMsg.getText().startsWith("jjc")) {
            if (groupMsg.getText().trim().equals("jjc")) {
                List<Herouser> herouser;
                if (groupMsg.getMsgContent().getCats().size() > 1) {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, groupMsg.getMsgContent().getCats().get(1).get("code")));
                } else {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, accountInfo.getAccountCode()));
                }
                if (herouser.size() == 0) {
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text("还未绑定角色！").build();
                    sender.sendGroupMsg(groupMsg, msg);
                } else {
                    log.info("入参====>" + herouser);
                    String result = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + herouser.get(0).getRoleid() + "&MatchType=1&SearchIndex=1", new JSONObject(), String.class);
                    String result2 = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + herouser.get(0).getRoleid() + "&MatchType=1&SearchIndex=2", new JSONObject(), String.class);
                    String matchs = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                    String matchs2 = JSONObject.parseObject(result2).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                    List<JSONObject> matchsList = CommonUtil.jsonToList(matchs);
                    List<JSONObject> matchsList2 = CommonUtil.jsonToList(matchs2);
                    log.info("战绩" + result);
                    int i = 0;
                    String message = "[CAT:at,code=" + accountInfo.getAccountCode() + "][CAT:text,text=&#13;-----------------------------------&#13;]";
                    for (JSONObject match : matchsList) {
                        String player = match.getString("Players");
                        List<JSONObject> playerList = CommonUtil.jsonToList(player);
                        JSONObject play = playerList.get(0);
                        String player2;
                        JSONObject play2 = new JSONObject();
                        if (i <= 7) {
                            if (i==7){
                                play2.put("Elo",0);
                            }else {
                                player2 = matchsList.get(i + 1).getString("Players");
                                List<JSONObject> playerList2 = CommonUtil.jsonToList(player2);
                                play2 = playerList2.get(0);
                            }
                        } else {
                            player2 = matchsList2.get(0).getString("Players");
                            List<JSONObject> playerList2 = CommonUtil.jsonToList(player2);
                            play2 = playerList2.get(0);
                        }
                        int elo2 = new Double(Double.valueOf(play2.getString("Elo"))).intValue();


                        int results = new Double(Double.valueOf(play.getString("Result"))).intValue();
                        int killPlayer = new Double(Double.valueOf(play.getString("KillPlayer"))).intValue();
                        int death = new Double(Double.valueOf(play.getString("Death"))).intValue();
                        int assist = new Double(Double.valueOf(play.getString("Assist"))).intValue();
                        int TotalMoney = new Double(Double.valueOf(play.getString("TotalMoney"))).intValue();
                        int heroID = new Double(Double.valueOf(play.getString("HeroID"))).intValue();
                        int elo = new Double(Double.valueOf(play.getString("Elo"))).intValue();

                        System.out.println("heroID=====>" + heroID);
                        Herosinformation heroName = herosinformationMapper.selectOne(Wrappers.<Herosinformation>lambdaQuery().eq(Herosinformation::getHeroid, heroID));
                        if (heroName == null) {
                            log.info(String.valueOf(heroID));
                            heroName.setHeroname(String.valueOf(heroID));
                        }
                        if (results == 1) {
                            message = message + "[CAT:face,id=178]";
                        } else {
                            message = message + "[CAT:face,id=10]";
                        }
                        message = message + "[CAT:text,text= " + heroName.getHeroname() + ": " + killPlayer + "/" + death + "/" + assist + "   " + elo + "(" + ((elo - elo2) > 0 ? "+" + (elo - elo2) : (elo - elo2)) + ")" + "&#13;]";
                        i++;
                    }
//                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text(message).build();
                    sender.sendGroupMsg(groupMsg, message);
                }
            } else {
                String getName = groupMsg.getText().trim().substring(3);
                String result1 = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchNormal?type=wx/AccountID=0&Guid=0&RoleName=" + getName, new JSONObject(), String.class);
                JSONObject data1 = JSONObject.parseObject(result1).getJSONObject("data");
                Long roleID = data1.getLong("RoleID");
                log.info("roleID====>" + roleID);
                String url = "https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + roleID + "&MatchType=1&SearchIndex=1";
                String result = restTemplate.postForObject(url, new JSONObject(), String.class);
                String result2 = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + roleID + "&MatchType=1&SearchIndex=2", new JSONObject(), String.class);
                String matchs2 = JSONObject.parseObject(result2).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                List<JSONObject> matchsList2 = CommonUtil.jsonToList(matchs2);

                String matchs = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                List<JSONObject> matchsList = CommonUtil.jsonToList(matchs);


                String message = "[CAT:at,code=" + accountInfo.getAccountCode() + "][CAT:text,text=&#13;-----------------------------------&#13;]";

                int i = 0;
                for (JSONObject match : matchsList) {
                    String player = match.getString("Players");
                    List<JSONObject> playerList = CommonUtil.jsonToList(player);
                    JSONObject play = playerList.get(0);
                    int elo = new Double(Double.valueOf(play.getString("Elo"))).intValue();

                    String player2;
                    JSONObject play2;
                    int elo2 = 0;
                    try {
                        if (i < 7) {
                            player2 = matchsList.get(i + 1).getString("Players");
                            List<JSONObject> playerList2 = CommonUtil.jsonToList(player2);
                            play2 = playerList2.get(0);
                        } else {
                            player2 = matchsList2.get(0).getString("Players");
                            List<JSONObject> playerList2 = CommonUtil.jsonToList(player2);
                            play2 = playerList2.get(0);
                        }
                        elo2 = new Double(Double.valueOf(play2.getString("Elo"))).intValue();
                    } catch (Exception ignored) {
                        elo2 = elo;
                    }

                    int results = new Double(Double.valueOf(play.getString("Result"))).intValue();
                    int killPlayer = new Double(Double.valueOf(play.getString("KillPlayer"))).intValue();
                    int death = new Double(Double.valueOf(play.getString("Death"))).intValue();
                    int assist = new Double(Double.valueOf(play.getString("Assist"))).intValue();
                    int TotalMoney = new Double(Double.valueOf(play.getString("TotalMoney"))).intValue();
                    int heroID = new Double(Double.valueOf(play.getString("HeroID"))).intValue();

                    log.info("heroID====>" + heroID);
                    Herosinformation heroName = herosinformationMapper.selectOne(Wrappers.<Herosinformation>lambdaQuery().eq(Herosinformation::getHeroid, heroID));
                    if (results == 1) {
                        message = message + "[CAT:face,id=178]";
                    } else {
                        message = message + "[CAT:face,id=10]";
                    }
                    message = message + "[CAT:text,text= " + heroName.getHeroname() + ": " + killPlayer + "/" + death + "/" + assist + "   " + elo + "(" + ((elo - elo2) > 0 ? "+" + (elo - elo2) : (elo - elo2)) + ")" + "&#13;]";
                    i++;
                }
//                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text(message).build();
                sender.sendGroupMsg(groupMsg, message);

            }
        }

        if (groupMsg.getText().startsWith("pw")) {
            if (groupMsg.getText().trim().equals("pw")) {
                List<Herouser> herouser;
                if (groupMsg.getMsgContent().getCats().size() > 1) {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, groupMsg.getMsgContent().getCats().get(1).get("code")));
                } else {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, accountInfo.getAccountCode()));
                }
                if (herouser.size() == 0) {
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text("还未绑定角色！").build();
                    sender.sendGroupMsg(groupMsg, msg);
                } else {
                    String result = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + herouser.get(0).getRoleid() + "&MatchType=3&SearchIndex=1", new JSONObject(), String.class);
                    String matchs = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                    List<JSONObject> matchsList = CommonUtil.jsonToList(matchs);


                    String message = "[CAT:at,code=" + accountInfo.getAccountCode() + "][CAT:text,text=&#13;-----------------------------------&#13;]";
                    for (JSONObject match : matchsList) {
                        String player = match.getString("Players");
                        List<JSONObject> playerList = CommonUtil.jsonToList(player);
                        JSONObject play = playerList.get(0);
                        int results = new Double(Double.valueOf(play.getString("Result"))).intValue();
                        int killPlayer = new Double(Double.valueOf(play.getString("KillPlayer"))).intValue();
                        int death = new Double(Double.valueOf(play.getString("Death"))).intValue();
                        int assist = new Double(Double.valueOf(play.getString("Assist"))).intValue();
                        int TotalMoney = new Double(Double.valueOf(play.getString("TotalMoney"))).intValue();
                        int heroID = new Double(Double.valueOf(play.getString("HeroID"))).intValue();
                        Herosinformation heroName = herosinformationMapper.selectOne(Wrappers.<Herosinformation>lambdaQuery().eq(Herosinformation::getHeroid, heroID));
                        if (results == 1) {
                            message = message + "[CAT:face,id=178]";
                        } else {
                            message = message + "[CAT:face,id=10]";
                        }
                        message = message + "[CAT:text,text= " + heroName.getHeroname() + ": " + killPlayer + "/" + death + "/" + assist + "/" + TotalMoney + "&#13;]";
                    }
//                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text(message).build();
                    sender.sendGroupMsg(groupMsg, message);
                }
            } else {
                String getName = groupMsg.getText().trim().substring(2);
                String result1 = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchNormal?type=wx/AccountID=0&Guid=0&RoleName=" + getName, new JSONObject(), String.class);
                JSONObject data1 = JSONObject.parseObject(result1).getJSONObject("data");
                Long roleID = data1.getLong("RoleID");
                String url = "https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + roleID + "&MatchType=3&SearchIndex=1";
                String result = restTemplate.postForObject(url, new JSONObject(), String.class);
                String matchs = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                List<JSONObject> matchsList = CommonUtil.jsonToList(matchs);

                String message = "[CAT:at,code=" + accountInfo.getAccountCode() + "][CAT:text,text=&#13;-----------------------------------&#13;]";
                for (JSONObject match : matchsList) {
                    String player = match.getString("Players");
                    List<JSONObject> playerList = CommonUtil.jsonToList(player);
                    JSONObject play = playerList.get(0);
                    int results = new Double(Double.valueOf(play.getString("Result"))).intValue();
                    int killPlayer = new Double(Double.valueOf(play.getString("KillPlayer"))).intValue();
                    int death = new Double(Double.valueOf(play.getString("Death"))).intValue();
                    int assist = new Double(Double.valueOf(play.getString("Assist"))).intValue();
                    int TotalMoney = new Double(Double.valueOf(play.getString("TotalMoney"))).intValue();
                    int heroID = new Double(Double.valueOf(play.getString("HeroID"))).intValue();
                    Herosinformation heroName = herosinformationMapper.selectOne(Wrappers.<Herosinformation>lambdaQuery().eq(Herosinformation::getHeroid, heroID));
                    if (results == 1) {
                        message = message + "[CAT:face,id=178]";
                    } else {
                        message = message + "[CAT:face,id=10]";
                    }
                    message = message + "[CAT:text,text= " + heroName.getHeroname() + ": " + killPlayer + "/" + death + "/" + assist + "/" + TotalMoney + "&#13;]";
                }
//                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text(message).build();
                sender.sendGroupMsg(groupMsg, message);

            }

        }


        if (groupMsg.getText().startsWith("sdz")) {
            if (groupMsg.getText().trim().equals("sdz")) {
                List<Herouser> herouser;
                if (groupMsg.getMsgContent().getCats().size() > 1) {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, groupMsg.getMsgContent().getCats().get(1).get("code")));
                } else {
                    herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, accountInfo.getAccountCode()));
                }
                if (herouser.size() == 0) {
                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text("还未绑定角色！").build();
                    sender.sendGroupMsg(groupMsg, msg);
                } else {
                    String result = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + herouser.get(0).getRoleid() + "&MatchType=4&SearchIndex=1", new JSONObject(), String.class);
                    String matchs = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                    List<JSONObject> matchsList = CommonUtil.jsonToList(matchs);


                    String message = "[CAT:at,code=" + accountInfo.getAccountCode() + "][CAT:text,text=&#13;-----------------------------------&#13;]";
                    for (JSONObject match : matchsList) {
                        String player = match.getString("Players");
                        List<JSONObject> playerList = CommonUtil.jsonToList(player);
                        JSONObject play = playerList.get(0);
                        int results = new Double(Double.valueOf(play.getString("Result"))).intValue();
                        int killPlayer = new Double(Double.valueOf(play.getString("KillPlayer"))).intValue();
                        int death = new Double(Double.valueOf(play.getString("Death"))).intValue();
                        int assist = new Double(Double.valueOf(play.getString("Assist"))).intValue();
                        int TotalMoney = new Double(Double.valueOf(play.getString("TotalMoney"))).intValue();
                        int heroID = new Double(Double.valueOf(play.getString("HeroID"))).intValue();
                        Herosinformation heroName = herosinformationMapper.selectOne(Wrappers.<Herosinformation>lambdaQuery().eq(Herosinformation::getHeroid, heroID));
                        if (results == 1) {
                            message = message + "[CAT:face,id=178]";
                        } else {
                            message = message + "[CAT:face,id=10]";
                        }
                        message = message + "[CAT:text,text= " + heroName.getHeroname() + ": " + killPlayer + "/" + death + "/" + assist + "/" + TotalMoney + "&#13;]";
                    }
//                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text(message).build();
                    sender.sendGroupMsg(groupMsg, message);
                }
            } else {
                String getName = groupMsg.getText().trim().substring(3);
                String result1 = restTemplate.postForObject("https://m300wxapp.jumpw.com/battle/searchNormal?type=wx/AccountID=0&Guid=0&RoleName=" + getName, new JSONObject(), String.class);
                JSONObject data1 = JSONObject.parseObject(result1).getJSONObject("data");
                Long roleID = data1.getLong("RoleID");
                String url = "https://m300wxapp.jumpw.com/battle/searchMatchs?type=wx&RoleID=" + roleID + "&MatchType=4&SearchIndex=1";
                String result = restTemplate.postForObject(url, new JSONObject(), String.class);
                String matchs = JSONObject.parseObject(result).getJSONObject("data").getJSONObject("Matchs").getString("Matchs");
                List<JSONObject> matchsList = CommonUtil.jsonToList(matchs);


                String message = "[CAT:at,code=" + accountInfo.getAccountCode() + "][CAT:text,text=&#13;-----------------------------------&#13;]";
                for (JSONObject match : matchsList) {
                    String player = match.getString("Players");
                    List<JSONObject> playerList = CommonUtil.jsonToList(player);
                    JSONObject play = playerList.get(0);
                    int results = new Double(Double.valueOf(play.getString("Result"))).intValue();
                    int killPlayer = new Double(Double.valueOf(play.getString("KillPlayer"))).intValue();
                    int death = new Double(Double.valueOf(play.getString("Death"))).intValue();
                    int assist = new Double(Double.valueOf(play.getString("Assist"))).intValue();
                    int TotalMoney = new Double(Double.valueOf(play.getString("TotalMoney"))).intValue();
                    int heroID = new Double(Double.valueOf(play.getString("HeroID"))).intValue();
                    Herosinformation heroName = herosinformationMapper.selectOne(Wrappers.<Herosinformation>lambdaQuery().eq(Herosinformation::getHeroid, heroID));
                    if (results == 1) {
                        message = message + "[CAT:face,id=178]";
                    } else {
                        message = message + "[CAT:face,id=10]";
                    }
                    message = message + "[CAT:text,text= " + heroName.getHeroname() + ": " + killPlayer + "/" + death + "/" + assist + "/" + TotalMoney + "&#13;]";
                }
//                    MessageContent msg = builder.at(accountInfo.getAccountCode()).text(message).build();
                sender.sendGroupMsg(groupMsg, message);

            }

        }
        if (groupMsg.getText().trim().equals("我的角色")) {
            List<Herouser> herouser;
            herouser = herouserMapper.selectList(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getUsername, accountInfo.getAccountCode()));
            String s = "";
            for (Herouser h : herouser) {
                s = s + h.getRolename() + "\n";
            }
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n" + s).build();
            sender.sendGroupMsg(groupMsg, msg);
        }
        if (groupMsg.getText().trim().startsWith("解除绑定")) {
            String roleName = groupMsg.getText().substring(4).trim();
            herouserMapper.delete(Wrappers.<Herouser>lambdaQuery().eq(Herouser::getRolename, roleName));
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("解除成功！").build();
            sender.sendGroupMsg(groupMsg, msg);
        }

    }


    //抽签用类
    @OnGroup
    @Filter(value = "抽签", matchType = MatchType.EQUALS, trim = true)
    public void chouQian(GroupMsg groupMsg, Sender sender) {
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
        AccountInfo accountInfo = groupMsg.getAccountInfo();
        String now = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now());
        List<CommonUser> commonUserList = commonUserMapper.selectList(Wrappers.<CommonUser>lambdaQuery().eq(CommonUser::getUserNum, accountInfo.getAccountCode()));
        int getId = (int) (Math.random() * 99 + 1);
        if (commonUserList.size() > 0) {
            if (!commonUserList.get(0).getIsFeed().equals(now)) {
                String result = restTemplate.getForObject("https://sl.yeyuewen.com/qian?name=guanyin&id=" + getId, String.class);
                commonUserList.get(0).setBelief(String.valueOf(getId));
                commonUserList.get(0).setIsFeed(now);
                commonUserMapper.update(commonUserList.get(0), Wrappers.<CommonUser>lambdaQuery().eq(CommonUser::getUserNum, accountInfo.getAccountCode()));
                JSONObject data = JSONObject.parseObject(result).getJSONObject("data");
                String sendString = data.getString("title") + "第" + getId + "签\n" + data.getString("jxgw") + "\n签词\n" + data.getString("qy") + "\n诗意\n" + data.getString("sy") + "\n解曰\n" + data.getString("jy") + "\n仙机";
                List<JSONObject> xj = CommonUtil.jsonToList(data.getString("xj"));
                for (JSONObject object : xj) {
                    sendString = sendString + "\n" + object.getString("name") + "  " + object.getString("value");
                }
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n" + sendString).build();
                sender.sendGroupMsg(groupMsg, msg);
            } else {
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n一天一次才准哦！").build();
                sender.sendGroupMsg(groupMsg, msg);
            }
        } else {
            CommonUser commonUser = new CommonUser();
            commonUser.setUserNum(accountInfo.getAccountCode());
            String yesterday = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now().minusDays(1));
            commonUser.setIsSign(yesterday);
            commonUser.setIsFeed(now);
            commonUser.setBelief(String.valueOf(getId));
            commonUserMapper.insert(commonUser);
            String result = restTemplate.getForObject("https://sl.yeyuewen.com/qian?name=guanyin&id=" + getId, String.class);
            JSONObject data = JSONObject.parseObject(result).getJSONObject("data");
            String sendString = data.getString("title") + "第" + getId + "签\n" + data.getString("jxgw") + "\n签词\n" + data.getString("qy") + "\n诗意\n" + data.getString("sy") + "\n解曰\n" + data.getString("jy") + "\n仙机";
            List<JSONObject> xj = CommonUtil.jsonToList(data.getString("xj"));
            for (JSONObject object : xj) {
                sendString = sendString + "\n" + object.getString("name") + "  " + object.getString("value");
            }
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n" + sendString).build();
            sender.sendGroupMsg(groupMsg, msg);
        }
    }

    //解签用类
    @OnGroup
    @Filter(value = "解签", matchType = MatchType.EQUALS, trim = true)
    public void jieQian(GroupMsg groupMsg, Sender sender) {
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
        AccountInfo accountInfo = groupMsg.getAccountInfo();
        String now = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now());
        List<CommonUser> commonUserList = commonUserMapper.selectList(Wrappers.<CommonUser>lambdaQuery().eq(CommonUser::getUserNum, accountInfo.getAccountCode()));
        if (commonUserList.size() == 0) {
            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n你今天还没有抽签哦!").build();
            sender.sendGroupMsg(groupMsg, msg);
        } else {
            if (commonUserList.get(0).getIsFeed().equals(now)) {
                String result = restTemplate.getForObject("https://sl.yeyuewen.com/qian?name=guanyin&id=" + commonUserList.get(0).getBelief(), String.class);
                JSONObject data = JSONObject.parseObject(result).getJSONObject("data");
                List<JSONObject> list = CommonUtil.jsonToList(data.getString("list"));
                String sendString = "";
                for (JSONObject object : list) {
                    sendString = sendString + "\n" + object.getString("title") + "\n";
                    JSONArray items = JSONArray.parseArray(object.getString("items"));
                    for (Object item : items) {
                        sendString = sendString + item.toString();
                    }
                }
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text(sendString).build();
                sender.sendGroupMsg(groupMsg, msg);
            } else {
                MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n你今天还没有抽签哦!").build();
                sender.sendGroupMsg(groupMsg, msg);
            }
        }
    }

    @OnGroup
    @Filter(value = "点歌", matchType = MatchType.STARTS_WITH, trim = true)
    public void song(GroupMsg groupMsg, Sender sender) {
        int i = 0;
        String name = groupMsg.getText().replace("点歌", "").trim();
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
        String s = restTemplate.postForObject("https://autumnfish.cn/search?keywords=" + name, new JSONObject(), String.class);
        JSONObject result = JSONObject.parseObject(s).getJSONObject("result");
        List<JSONObject> list = CommonUtil.jsonToList(result.getString("songs"));
        String musicUrl = "https://music.163.com/song/media/outer/url?id=" + list.get(i).getString("id");
//        if (null==data.get(0).getString("url")){
//            i++;
//            getUrl = restTemplate.postForObject("https://music.163.com/song/media/outer/url?id="+list.get(i).getString("id"),new JSONObject() ,String.class);
//            data = CommonUtil.jsonToList(JSONObject.parseObject(getUrl).getString("data"));
//        }
        List<JSONObject> artists = CommonUtil.jsonToList(list.get(0).getString("artists"));
        String Cat = "[CAT:music,type=163,musicUrl=" + musicUrl + ",title=" + list.get(i).getString("name") + ",content=" + artists.get(0).getString("name") + ",pictureUrl=" + artists.get(0).getString("img1v1Url") + "]";
        sender.sendGroupMsg(groupMsg, Cat);
    }

    @OnGroup
    @Filter(value = "投喂", matchType = MatchType.CONTAINS, trim = true)
    @Filter(value = "投食", matchType = MatchType.CONTAINS, trim = true)
    @Filter(value = "喂食", matchType = MatchType.CONTAINS, trim = true)
    public void signIn(GroupMsg groupMsg, Sender sender) {
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
        AccountInfo accountInfo = groupMsg.getAccountInfo();
        String msgStr = "";
        List<SignUser> commonUserList = signUserMapper.selectList(Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
        if (commonUserList.size() < 1) {
            SignUser signUser = new SignUser();
            signUser.setUsername(accountInfo.getAccountCode());
            signUser.setIsSign(LocalDateTime.now());
            signUser.setBelief(1);
            signUser.setMoney(1);
            signUser.setIsGetMoney(LocalDate.now());
            signUser.setIsWork(LocalDate.now().minusDays(1));
            signUserMapper.insert(signUser);
            Information information = informationMapper.selectById(1);
            information.setSatiety(information.getSatiety().add(new BigDecimal("4.00")));
            informationMapper.updateById(information);
            msgStr = msgStr + "你人还不错啦。";
        } else {
            if (commonUserList.get(0).getIsSign().isAfter(LocalDateTime.now())) {
                msgStr = msgStr + "人家吃不下了啦~";
            } else {
                commonUserList.get(0).setIsSign(LocalDateTime.now().plusHours(6));
                commonUserList.get(0).setBelief(commonUserList.get(0).getBelief() + 1);
                if (commonUserList.get(0).getIsGetMoney().isBefore(LocalDate.now())) {
                    commonUserList.get(0).setMoney(commonUserList.get(0).getMoney() + 1);
                    commonUserList.get(0).setIsGetMoney(LocalDate.now());
                }
                signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                Information information = informationMapper.selectById(1);
                information.setSatiety(information.getSatiety().add(new BigDecimal("4.00")));
                informationMapper.updateById(information);
                msgStr = msgStr + "你人还不错啦。";
            }
        }


        MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n" + msgStr).build();
        sender.sendGroupMsg(groupMsg, msg);
    }

    @OnGroup
    @Filter(value = "赠送", matchType = MatchType.CONTAINS, trim = true)
    public void sendGift(GroupMsg groupMsg, Sender sender) {
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
        AccountInfo accountInfo = groupMsg.getAccountInfo();
        String msgStr = "";
        List<SignUser> commonUserList = signUserMapper.selectList(Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
        if (commonUserList.size() < 1) {
            msgStr = "你什么都没有捏。";
        } else {
            if (groupMsg.getText().replace("赠送", "").equals("咖啡")) {
                List<ItemsJiu> itemsJiuList = itemsJiuMapper.selectList(Wrappers.<ItemsJiu>lambdaQuery().eq(ItemsJiu::getUsername, accountInfo.getAccountCode()).eq(ItemsJiu::getItemname, "咖啡"));
                if (itemsJiuList.get(0).getQuantity() > 0) {
                    itemsJiuList.get(0).setQuantity(itemsJiuList.get(0).getQuantity() - 1);
                    commonUserList.get(0).setBelief(commonUserList.get(0).getBelief() + 1);
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    itemsJiuMapper.update(itemsJiuList.get(0), Wrappers.<ItemsJiu>lambdaQuery().eq(ItemsJiu::getUsername, accountInfo.getAccountCode()).eq(ItemsJiu::getItemname, "咖啡"));
                    msgStr = "谢谢你的咖啡~你人真好";
                    Information information = informationMapper.selectById(1);
                    information.setSatiety(information.getSatiety().add(new BigDecimal("10.00")));
                    informationMapper.updateById(information);
                } else {
                    msgStr = "骗我你根本就没有";
                }

            }
            if (groupMsg.getText().replace("赠送", "").equals("奶茶")) {
                List<ItemsJiu> itemsJiuList = itemsJiuMapper.selectList(Wrappers.<ItemsJiu>lambdaQuery().eq(ItemsJiu::getUsername, accountInfo.getAccountCode()).eq(ItemsJiu::getItemname, "奶茶"));
                if (itemsJiuList.get(0).getQuantity() > 0) {
                    itemsJiuList.get(0).setQuantity(itemsJiuList.get(0).getQuantity() - 1);
                    commonUserList.get(0).setBelief(commonUserList.get(0).getBelief() + 5);
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    itemsJiuMapper.update(itemsJiuList.get(0), Wrappers.<ItemsJiu>lambdaQuery().eq(ItemsJiu::getUsername, accountInfo.getAccountCode()).eq(ItemsJiu::getItemname, "奶茶"));
                    msgStr = "谢谢你的奶茶~你人真好";
                    Information information = informationMapper.selectById(1);
                    information.setSatiety(information.getSatiety().add(new BigDecimal("20.00")));
                    informationMapper.updateById(information);
                } else {
                    msgStr = "骗我你根本就没有";
                }

            }
            if (groupMsg.getText().replace("赠送", "").equals("蛋糕")) {
                List<ItemsJiu> itemsJiuList = itemsJiuMapper.selectList(Wrappers.<ItemsJiu>lambdaQuery().eq(ItemsJiu::getUsername, accountInfo.getAccountCode()).eq(ItemsJiu::getItemname, "蛋糕"));
                if (itemsJiuList.get(0).getQuantity() > 0) {
                    itemsJiuList.get(0).setQuantity(itemsJiuList.get(0).getQuantity() - 1);
                    commonUserList.get(0).setBelief(commonUserList.get(0).getBelief() + 12);
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    itemsJiuMapper.update(itemsJiuList.get(0), Wrappers.<ItemsJiu>lambdaQuery().eq(ItemsJiu::getUsername, accountInfo.getAccountCode()).eq(ItemsJiu::getItemname, "蛋糕"));
                    msgStr = "谢谢你的蛋糕~你人真好";
                    Information information = informationMapper.selectById(1);
                    information.setSatiety(information.getSatiety().add(new BigDecimal("30.00")));
                    informationMapper.updateById(information);
                } else {
                    msgStr = "骗我你根本就没有";
                }

            }
        }
        MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n" + msgStr).build();
        sender.sendGroupMsg(groupMsg, msg);
    }

    @OnGroup
    @Filter(value = "信仰", matchType = MatchType.EQUALS, trim = true)
    public void belif(GroupMsg groupMsg, Sender sender) {
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
        AccountInfo accountInfo = groupMsg.getAccountInfo();
        String msgStr = "";
        List<SignUser> commonUserList = signUserMapper.selectList(Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
        List<ItemsJiu> itemsJiuList = itemsJiuMapper.selectList(Wrappers.<ItemsJiu>lambdaQuery().eq(ItemsJiu::getUsername, accountInfo.getAccountCode()));
        if (commonUserList.size() < 1) {
            SignUser signUser = new SignUser();
            signUser.setUsername(accountInfo.getAccountCode());
            signUser.setIsSign(LocalDateTime.now().minusDays(1));
            signUser.setBelief(0);
            signUser.setMoney(0);
            signUser.setIsWork(LocalDate.now().minusDays(1));
            signUserMapper.insert(signUser);
            CommonUtil.getImage(accountInfo.getAccountNickname(), signUser.getBelief(), signUser.getMoney(), "无", itemsJiuList);
//            MessageContent msg = builder.text("\n信仰：" + commonUserList.get(0).getBelief() + "\n金币：" + commonUserList.get(0).getMoney()).build();
            MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\图库\\2.jpg").build();
            sender.sendGroupMsg(groupMsg, msg);
        } else {
//            MessageContent msg = builder.at(accountInfo.getAccountCode()).text("\n信仰：" + commonUserList.get(0).getBelief() + "\n金币：" + commonUserList.get(0).getMoney()).build();
            CommonUtil.getImage(accountInfo.getAccountNickname(), commonUserList.get(0).getBelief(), commonUserList.get(0).getMoney(), commonUserList.get(0).getRecord(), itemsJiuList);
            MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\图库\\2.jpg").build();
            sender.sendGroupMsg(groupMsg, msg);
        }
    }

//    @OnGroup
//    @Filter(value = "早苗以后叫我", matchType = MatchType.STARTS_WITH, trim = true)
//    public void customize(GroupMsg groupMsg, Sender sender) {
//        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
//        AccountInfo accountInfo = groupMsg.getAccountInfo();
//        String now = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now().minusDays(1));
//        String anotherName = groupMsg.getText().replace("早苗以后叫我", "").trim();
//        List<SignUser> commonUserList = signUserMapper.selectList(Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
//        if (commonUserList.size() > 0) {
//            commonUserList.get(0).setAnotherName(anotherName);
//            signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
//        } else {
//            SignUser signUser = new SignUser();
//            signUser.setUsername(accountInfo.getAccountCode());
//            signUser.setIsSign(now);
//            signUser.setBelief(0);
//            signUser.setAnotherName(anotherName);
//            signUserMapper.insert(signUser);
//        }
//        MessageContent msg = builder.text("好的" + anotherName + "。").build();
//        sender.sendGroupMsg(groupMsg, msg);
//    }
//
//    @OnGroup
//    @Filter(value = "我是谁", matchType = MatchType.STARTS_WITH, trim = true)
//    public void myName(GroupMsg groupMsg, Sender sender) {
//        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
//        AccountInfo accountInfo = groupMsg.getAccountInfo();
//        String now = DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDateTime.now().minusDays(1));
//        List<SignUser> commonUserList = signUserMapper.selectList(Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
//        if (commonUserList.size() > 0) {
//            if (null == commonUserList.get(0).getAnotherName()) {
//                MessageContent msg = builder.text(accountInfo.getAccountNickname()).build();
//                sender.sendGroupMsg(groupMsg, msg);
//            } else {
//                MessageContent msg = builder.text(commonUserList.get(0).getAnotherName()).build();
//                sender.sendGroupMsg(groupMsg, msg);
//            }
//        } else {
//            SignUser signUser = new SignUser();
//            signUser.setUsername(accountInfo.getAccountCode());
//            signUser.setIsSign(now);
//            signUser.setBelief(0);
//            signUserMapper.insert(signUser);
//            MessageContent msg = builder.text(accountInfo.getAccountNickname()).build();
//            sender.sendGroupMsg(groupMsg, msg);
//        }
//
//    }


    @OnGroup
    public void shop(GroupMsg groupMsg, Sender sender) {
        if (groupMsg.getText().equals("早苗商店")) {
            MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
            MessageContent msg = builder.text("咖啡（+1信仰）金币5\n奶茶（+5信仰）金币15\n蛋糕（+12信仰）金币30\n\n\n注：捡瓶子（金币1-3个）风险无\n偷东西（金币3-6个）风险30%进牢房关2天\n抢劫（金币20-30个）风险70%进监狱关5天").build();
            sender.sendGroupMsg(groupMsg, msg);
        }
    }

    @OnGroup
    public void buyItem(GroupMsg groupMsg, Sender sender) {
        if (groupMsg.getText().startsWith("购买")) {
            MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
            AccountInfo accountInfo = groupMsg.getAccountInfo();
            List<SignUser> commonUserList = signUserMapper.selectList(Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
            if (commonUserList.size() < 1) {
                sender.sendGroupMsg(groupMsg, "金币不足！");
                return;
            }
            String itemName = groupMsg.getText().replace("购买", "");
            if (itemName.equals("咖啡")) {
                if (commonUserList.get(0).getMoney() >= 5) {
                    commonUserList.get(0).setMoney(commonUserList.get(0).getMoney() - 5);
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    buyItem.buy("咖啡", accountInfo.getAccountCode());
                    sender.sendGroupMsg(groupMsg, "购买成功！");
                } else {
                    sender.sendGroupMsg(groupMsg, "金币不足！");
                    return;
                }
            }
            if (itemName.equals("奶茶")) {
                if (commonUserList.get(0).getMoney() >= 15) {
                    commonUserList.get(0).setMoney(commonUserList.get(0).getMoney() - 15);
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    buyItem.buy("奶茶", accountInfo.getAccountCode());
                    sender.sendGroupMsg(groupMsg, "购买成功！");
                } else {
                    sender.sendGroupMsg(groupMsg, "金币不足！");
                    return;
                }
            }
            if (itemName.equals("蛋糕")) {
                if (commonUserList.get(0).getMoney() >= 30) {
                    commonUserList.get(0).setMoney(commonUserList.get(0).getMoney() - 30);
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    buyItem.buy("蛋糕", accountInfo.getAccountCode());
                    sender.sendGroupMsg(groupMsg, "购买成功！");
                } else {
                    sender.sendGroupMsg(groupMsg, "金币不足！");
                    return;
                }
            }
        }
    }

    @OnGroup
    @Filter(value = "捡瓶子", matchType = MatchType.EQUALS, trim = true)
    @Filter(value = "偷东西", matchType = MatchType.EQUALS, trim = true)
    @Filter(value = "抢劫", matchType = MatchType.EQUALS, trim = true)
    public void getMoney(GroupMsg groupMsg, Sender sender) {
        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
        AccountInfo accountInfo = groupMsg.getAccountInfo();
        MessageContent msg = null;
        List<SignUser> commonUserList = signUserMapper.selectList(Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
        SignUser signUser = new SignUser();
        if (commonUserList.size() < 1) {
            signUser.setUsername(accountInfo.getAccountCode());
            signUser.setIsSign(LocalDateTime.now().minusDays(1));
            signUser.setBelief(0);
            signUser.setMoney(0);
            signUser.setIsWork(LocalDate.now());
            signUser.setIsClose(LocalDate.now().minusDays(1));
            signUser.setIsGetMoney(LocalDate.now().minusDays(1));
            signUserMapper.insert(signUser);
            commonUserList.add(signUser);
        }
        if (commonUserList.get(0).getIsWork().isBefore(LocalDate.now()) && commonUserList.get(0).getIsClose().isBefore(LocalDate.now())) {
            if (groupMsg.getText().equals("捡瓶子")) {
                int rand = (int) ((Math.random() * 2) + 1);
                commonUserList.get(0).setMoney(commonUserList.get(0).getMoney() + rand);
                commonUserList.get(0).setIsWork(LocalDate.now());
                commonUserList.get(0).setRecord(DateTime.now().toString("yyyy年MM月dd日") + "捡瓶子获得" + rand + "金币");
                signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                msg = builder.at(accountInfo.getAccountCode()).text("你在人来人往的街道上翻着垃圾桶里的瓶子同时被一堆人看着。").build();
            }
            if (groupMsg.getText().equals("偷东西")) {
                if ((int) ((Math.random() * 100)) <= 30) {
                    commonUserList.get(0).setIsWork(LocalDate.now().plusDays(2));
                    commonUserList.get(0).setIsClose(LocalDate.now().plusDays(2));
                    commonUserList.get(0).setRecord(DateTime.now().toString("yyyy年MM月dd日") + "偷东西被抓坐牢两天");
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    msg = builder.at(accountInfo.getAccountCode()).text("你被热心的市民看到被毒打了一顿按在地上等待警察的到来··你被拘留了（坐牢5天）.").build();
                } else {
                    int rand = (int) ((Math.random() * 3) + 3);
                    commonUserList.get(0).setMoney(commonUserList.get(0).getMoney() + rand);
                    commonUserList.get(0).setIsWork(LocalDate.now());
                    commonUserList.get(0).setRecord(DateTime.now().toString("yyyy年MM月dd日") + "偷东西获得" + rand + "金币");
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    msg = builder.at(accountInfo.getAccountCode()).text("你在繁华的街道上使用以往惯用的手法摸着别人身上值钱的东西.").build();
                }
            }
            if (groupMsg.getText().equals("抢劫")) {
                if ((int) ((Math.random() * 100)) <= 70) {
                    commonUserList.get(0).setIsWork(LocalDate.now().plusDays(5));
                    commonUserList.get(0).setIsClose(LocalDate.now().plusDays(5));
                    commonUserList.get(0).setRecord(DateTime.now().toString("yyyy年MM月dd日") + "抢劫被抓坐牢五天");
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    msg = builder.at(accountInfo.getAccountCode()).text("你一进去看到了一堆特警 特警看到你手上的枪后 立刻把你就地抓捕（坐牢5天）").build();
                } else {
                    int rand = (int) ((Math.random() * 10) + 10);
                    commonUserList.get(0).setMoney(commonUserList.get(0).getMoney() + rand);
                    commonUserList.get(0).setIsWork(LocalDate.now());
                    commonUserList.get(0).setRecord(DateTime.now().toString("yyyy年MM月dd日") + "抢劫获得" + rand + "金币");
                    signUserMapper.update(commonUserList.get(0), Wrappers.<SignUser>lambdaQuery().eq(SignUser::getUsername, accountInfo.getAccountCode()));
                    msg = builder.at(accountInfo.getAccountCode()).text("你看着眼前的银行心理冒出一个大胆的想法 你整装待发的冲进银行.").build();
                }
            }
        } else {
            if (commonUserList.get(0).getIsClose().isBefore(LocalDate.now())) {
                msg = builder.at(accountInfo.getAccountCode()).text("每天只能做一件事哦！").build();
            } else {
                msg = builder.at(accountInfo.getAccountCode()).text("还在劳改中哦！").build();
            }
        }

        sender.sendGroupMsg(groupMsg, msg);
    }


//    五子棋功能不建议在群中使用，私聊有开放
//    public static HashMap<String,int[][]> map = new HashMap<>();
//    public static String playName = "";
//    @OnGroup
//    @Filter(value = "五子棋", matchType = MatchType.EQUALS, trim = true)
//    public void playWuZiQi(GroupMsg groupMsg, Sender sender) {
//        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
//        MessageContent messageContent = builder.imageLocal("D:\\steam\\steamapps\\common\\wuzi\\棋盘.jpg").build();
//        sender.sendGroupMsg(groupMsg, messageContent);
//        sender.sendGroupMsg(groupMsg, "输入坐标落子");
//        playName=groupMsg.getAccountInfo().getAccountCode();
//        map.put(groupMsg.getAccountInfo().getAccountCode(),new int[15][15]);
//        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
//        try {
//            ImageIO.write(ImageIO.read(new File("D:\\steam\\steamapps\\common\\wuzi\\棋盘.jpg")),"JPG",outputStream);//将字节流进行后缀的修饰，并将图片放入字节流中
//        } catch (IOException ioException) {
//            ioException.printStackTrace();
//        }
//        byte[] content = outputStream.toByteArray();//得到字节流中的所有字节
//        try (BufferedOutputStream inputStream = new BufferedOutputStream(new FileOutputStream("D:\\steam\\steamapps\\common\\wuzi\\"+groupMsg.getAccountInfo().getAccountCode()+".jpg"))) {
//            //将所传过来的字节流中的字节设置为输出流
//            inputStream.write(content);//将字节写出到指定位置
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//
//
//    @OnGroup
//    public void luoZi(GroupMsg groupMsg, Sender sender) {
//        MessageContentBuilder builder = messageBuilderFactory.getMessageContentBuilder();
//        String test = groupMsg.getText();
//        if (groupMsg.getAccountInfo().getAccountCode().equals(playName)&&test.trim().length()==2){
//            char[] chars = test.toCharArray();
//            if (47<(int)chars[0]&&(int)chars[0]<58&&chars[1]-'0'<64&&chars[1]>48){
//                wzq.setQiPan(map.get(groupMsg.getAccountInfo().getAccountCode()));
//                boolean bai = wzq.bai((chars[1] - '0') - 49,(int) (chars[0]-'0')-1,  new File("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg"));
//                map.put(groupMsg.getAccountInfo().getAccountCode(),wzq.qiPan);
//                if (bai){
//                    MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg").build();
//                    sender.sendGroupMsg(groupMsg,msg);
//                    sender.sendGroupMsg(groupMsg,"你赢啦");
//                    map.remove(groupMsg.getAccountInfo().getAccountCode());
//                    return;
//                }
//                wzq.setQiPan(map.get(groupMsg.getAccountInfo().getAccountCode()));
//                boolean hei = wzq.hei(new File("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg"));
//                map.put(groupMsg.getAccountInfo().getAccountCode(),wzq.qiPan);
//                if (hei){
//                    MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg").build();
//                    sender.sendGroupMsg(groupMsg,msg);
//                    sender.sendGroupMsg(groupMsg,"我赢啦");
//                    return;
//                }
//                MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg").build();
//                sender.sendGroupMsg(groupMsg,msg);
//                sender.sendGroupMsg(groupMsg,"请落子");
//            }
//        }
//        if (groupMsg.getAccountInfo().getAccountCode().equals(playName)&&test.trim().length()==3){
//            char[] chars = test.toCharArray();
//            if ((int)chars[0]==49&&47<(int)chars[1]&&(int)chars[1]<58&&chars[2]-'0'<64&&chars[2]>48){
//                String s ="";
//                wzq.setQiPan(map.get(groupMsg.getAccountInfo().getAccountCode()));
//                boolean bai = wzq.bai((chars[2] - '0') - 49,Integer.parseInt(s+chars[0]+chars[1])-1,  new File("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg"));
//                map.put(groupMsg.getAccountInfo().getAccountCode(),wzq.qiPan);
//                if (bai){
//                    MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg").build();
//                    sender.sendGroupMsg(groupMsg,msg);
//                    sender.sendGroupMsg(groupMsg,"你赢啦");
//                    map.remove(groupMsg.getAccountInfo().getAccountCode());
//                    return;
//                }
//                wzq.setQiPan(map.get(groupMsg.getAccountInfo().getAccountCode()));
//                boolean hei = wzq.hei(new File("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg"));
//                map.put(groupMsg.getAccountInfo().getAccountCode(),wzq.qiPan);
//                if (hei){
//                    MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg").build();
//                    sender.sendGroupMsg(groupMsg,msg);
//                    sender.sendGroupMsg(groupMsg,"我赢啦");
//                    return;
//                }
//                MessageContent msg = builder.imageLocal("D:\\steam\\steamapps\\common\\wuzi\\" + groupMsg.getAccountInfo().getAccountCode() + ".jpg").build();
//                sender.sendGroupMsg(groupMsg,msg);
//                sender.sendGroupMsg(groupMsg,"请落子");
//            }
//        }
//    }

//    String lastMessage = "";
//
//    @OnGroup
//    public void caijixinxi(GroupMsg groupMsg) {
//        String files = "D:\\steam\\steamapps\\common\\图库\\";
//        if (lastMessage.equals("") && !groupMsg.getText().equals("")) {
//            lastMessage = groupMsg.getText();
//
//        } else {
//            Exercise exercise = new Exercise();
//            exercise.setQuestion(lastMessage);
//            String getText = groupMsg.getText();
//            String cat;
//            cat = "[CAT:text,text=" + getText + "]";
//            List<Neko> imageCats = groupMsg.getMsgContent().getCats("image");
//            for (Neko image : imageCats) {
//                File isExists = new File(files + image.get("id"));
//                if (!isExists.exists() && teacher1 != null) {
//                    CommonUtil.downloadPicture(image.get("url"), files + image.get("id"));
//                }
//                cat = cat + "[CAT:image,file=" + files + image.get("id") + "]";
//            }
//            exercise.setAnswer(cat);
//            if (lastMessage.length() > 2) {
//                exercise.setKeyword(lastMessage.trim().substring(lastMessage.length() / 2, lastMessage.length() / 2 + 2));
//            } else {
//                exercise.setKeyword(lastMessage);
//            }
//            exerciseMapper.insert(exercise);
//            lastMessage = "";
//        }
//    }
}
